-
Notifications
You must be signed in to change notification settings - Fork 1k
Spring starter declarative config #14062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Spring starter declarative config #14062
Conversation
|
🔧 The result from spotlessApply was committed to the PR branch. |
17d949a to
f81444f
Compare
|
@laurit can you help me figure out what the problem is? |
tried to fix that with cbb070b |
|
I can't figure out what change could have caused that. Is the solution to not used ConfigProperties in the agent config? |
Let's see if it's 7116de1 |
I don't think this is going to help. |
Why is it not failing on main? |
Because on main you don't have it in boot loader. Actually I was wrong about
|
That worked - thanks a lot! |
bf6b7f8 to
9427fe6
Compare
|
🔧 The result from spotlessApply was committed to the PR branch. |
482c0be to
5fcca3f
Compare
a011497 to
d803eb5
Compare
...lemetry/instrumentation/spring/autoconfigure/internal/resources/DistroComponentProvider.java
Outdated
Show resolved
Hide resolved
...io/opentelemetry/instrumentation/spring/autoconfigure/SpringDeclarativeConfigProperties.java
Outdated
Show resolved
Hide resolved
...lemetry/instrumentation/spring/autoconfigure/internal/resources/DistroComponentProvider.java
Outdated
Show resolved
Hide resolved
| return false; | ||
| } | ||
|
|
||
| private static boolean isPrimitive(Object object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since String is not primitive the name is slightly misleading. Perhaps something like isSimple would be a better fit.
Also it does not list all the primitive types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a copy of https://github.com/open-telemetry/opentelemetry-java/blob/89c797377767d7c58e3539158e865bed3b7abb24/sdk-extensions/incubator/src/main/java/io/opentelemetry/sdk/extension/incubator/fileconfig/YamlDeclarativeConfigProperties.java#L126 - so I'd like to keep it as close as possible
...io/opentelemetry/instrumentation/spring/autoconfigure/SpringDeclarativeConfigProperties.java
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/EmbeddedConfigFile.java
Outdated
Show resolved
Hide resolved
| static ObjectMapper getObjectMapper() { | ||
| try { | ||
| Field field = DeclarativeConfiguration.class.getDeclaredField("MAPPER"); | ||
| field.setAccessible(true); | ||
| return (ObjectMapper) field.get(null); | ||
| } catch (NoSuchFieldException | IllegalAccessException e) { | ||
| throw new DeclarativeConfigException("Failed to access ObjectMapper", e); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the reflection worth it? Any reason you wish to avoid creating the ObjectMapper instance yourself? Since the MAPPER is package private could also consider adding a class in the same package for reading that field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason
I want to make sure the config options don't diverge
static final ObjectMapper MAPPER;
static {
MAPPER =
new ObjectMapper()
// Create empty object instances for keys which are present but have null values
.setDefaultSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
// Boxed primitives which are present but have null values should be set to null, rather than
// empty instances
MAPPER.configOverride(String.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
MAPPER.configOverride(Integer.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
MAPPER.configOverride(Double.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
MAPPER.configOverride(Boolean.class).setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.SET));
}.. package protected
good idea - changed
.../src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/EmbeddedConfigFile.java
Outdated
Show resolved
Hide resolved
| // Ensure the list is large enough | ||
| while (list.size() <= index) { | ||
| list.add(null); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArrayList has ensureCapacity method that might simplify this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, this doesn't work, as ensureCapacity doesn't set the size
.../src/main/java/io/opentelemetry/instrumentation/spring/autoconfigure/EmbeddedConfigFile.java
Outdated
Show resolved
Hide resolved
|
@laurit thanks for the review! please check again 😄 |
Fixes #14048